//
//  CLRunLoopInputSource.h
//  RunloopTest
//
//  Created by Charles on 2016/10/7.
//  Copyright © 2016年 Charles. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol CLRunLoopInputSourceDelegate <NSObject>

- (void)activeInputSourceForPrintStringEvent:(NSString *)string;

@end

@interface CLRunLoopInputSource : NSObject

@property (assign,nonatomic) id<CLRunLoopInputSourceDelegate>delegate;

//初始化和销毁
- (instancetype)init;

- (void)addToCurrentRunLoop;

- (void)invalidate;

//处理事件
- (void)inputSourceFired;

//其他线程注册事件
- (void)addCommand:(NSInteger)command data:(NSData *)data;

- (void)addPrintCommandWithString:(NSString *)string;

- (void)fireAllCommandsOnRunLoop:(CFRunLoopRef)runLoop;

@end

@interface CLRunLoopContext : NSObject

@property (nonatomic,readonly) CFRunLoopRef runLoop;

@property (nonatomic,readonly) CLRunLoopInputSource *runLoopInputSource ;

- (instancetype)initWithSource:(CLRunLoopInputSource *)runLoopInputSource runLoop:(CFRunLoopRef)runLoop;

@end
